﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:ViewModel="clr-namespace:EcoProIT.UserControles.ViewModel" xmlns:DataLayer="clr-namespace:EcoProIT.DataLayer;assembly=EcoProIT.DataLayer" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" x:Class="EcoProIT.UserControles.View.DefineProduct" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.DataContext>
        <ViewModel:Product/>
    </UserControl.DataContext>
    <Grid>
        <DataGrid AutoGenerateColumns="False" CanUserDeleteRows="True" CanUserAddRows="False" Margin="10,0,10,10" ItemsSource="{Binding BillOfMaterials}" SelectedValue="{Binding SelectedConsumption, Mode=OneWayToSource}" Height="209" VerticalAlignment="Bottom" >
            <DataGrid.Columns>
                <DataGridTemplateColumn MinWidth="18" Header="Remove">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Delete"
    							Command="{Binding DataContext.DeleteConsumptionCommand, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
    							CommandParameter="{Binding}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Header="Consumable" Binding="{Binding Consumable.Name, Mode=OneWay}"
    				CanUserReorder="True" />
                <DataGridTextColumn Header="Amount"
    				Binding="{Binding Amount, Mode=OneWay}"
    				CanUserReorder="True" />

                <DataGridTextColumn Header="Unit"
    				Binding="{Binding UnitType, Mode=OneWay}"
    				CanUserReorder="True" />

            </DataGrid.Columns>
        </DataGrid>
        <ComboBox ItemsSource ="{x:Static DataLayer:ConnectLCIDB.Consumebles}"  SelectedValue="{Binding SelectedConsumption.Consumable}" DisplayMemberPath="Name" SelectedIndex="0"  HorizontalAlignment="Left" Margin="88,4,0,0" VerticalAlignment="Top"
    		Width="85" RenderTransformOrigin="0.933,0.348"  />
        <Label Content="Consums" Margin="6,4,0,0" 
    		VerticalAlignment="Top" HorizontalAlignment="Left" Width="77" />
        <xctk:DecimalUpDown Value="{Binding SelectedConsumption.Amount, UpdateSourceTrigger=PropertyChanged}" Margin="88,56,0,0" HorizontalAlignment="Left" Width="85"  VerticalAlignment="Top" />
        <Label Content="Amount" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="8,50,0,0" Width="94"/>
        <Button Content="Add Consumtion" Command="{Binding NewConsumptionCommand}" HorizontalAlignment="Left" Margin="198,54,0,0" VerticalAlignment="Top" />
    </Grid>
</UserControl>
